-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REGR: Fix IntervalIndex.map when result is object dtype #31232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -164,22 +164,6 @@ def __contains__(self, key: Any) -> bool: | |||
is_scalar(res) or isinstance(res, slice) or (is_list_like(res) and len(res)) | |||
) | |||
|
|||
# Try to run function on index first, and then on elements of index | |||
# Especially important for group-by functionality | |||
def map(self, mapper, na_action=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbrockmendel : do you have any issues with moving the map
definition in DatetimeIndexOpsMixin
down to ExtensionIndex
so it's shared with IntervalIndex
? This seems to more gracefully handle index specific attributes (e.g. freq
for DTI, closed
for II) than Index.map
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely on board with this if we can use this for the general case
@@ -808,6 +808,13 @@ def test_map_dictlike(self, mapper): | |||
result = index.map(mapper(expected, index)) | |||
tm.assert_index_equal(result, expected) | |||
|
|||
def test_map_str(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to write a common test for index.map(str)
that shared across all index types since it didn't look like we were generically testing something similar. Can remove this an write and IntervalIndex
specific test if that'd be preferred.
thanks @jschendel |
… is object dtype
… dtype (#31246) Co-authored-by: Jeremy Schendel <[email protected]>
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
No whatnew since this is a regression.